ROOT="$HOME/bochs/bin/kernel/"

nasm -g -I "${ROOT}include/" -f bin -o "${ROOT}build/mbr.bin"  "${ROOT}boot/mbr.S"
nasm -g -I "${ROOT}include/" -f bin -o "${ROOT}build/loader.bin" "${ROOT}boot/loader.S"
nasm -f elf -o "${ROOT}build/temp/print.o" "${ROOT}lib/kernel/print.S"

gcc -I "${ROOT}lib/kernel" -c -m32 -o "${ROOT}build/temp/kernel.o.m32" "${ROOT}kernel/kernel.c"
ld -Ttext 0xc0001500 -e main -m elf_i386 "${ROOT}build/temp/kernel.o.m32" "${ROOT}build/temp/print.o" -o "${ROOT}build/kernel.bin.m32"
rm "${ROOT}build/temp/kernel.o.m32"

dd if="${ROOT}build/mbr.bin" of="${ROOT}build/hd60M.img" bs=512 count=1 conv=notrunc
dd if="${ROOT}build/loader.bin" of="${ROOT}build/hd60M.img" bs=512 count=7 seek=2 conv=notrunc
dd if="${ROOT}build/kernel.bin.m32" of="${ROOT}build/hd60M.img" bs=512 count=200 seek=9 conv=notrunc
